home *** CD-ROM | disk | FTP | other *** search
- // -------------------------------------------------------------------------------------
- // ExecServer
- // -------------------------------------------------------------------------------------
- #import <objc/Object.h>
- #import <machkit/NXData.h>
-
- // -------------------------------------------------------------------------------------
- // possible return errors (Note: these may be shared with the executed process)
- #define RSRV_SUCCESS 0 // successful completion
- #define RSRV_ABORTED 0xF001 // process aborted
- #define RSRV_FORK 0xF002 // fork() failed
- #define RSRV_UNKNOWN 0xF003 // unknown error
- #define RSRV_BADPASSWD 0xF004 // Invalid user password
- #define RSRV_BADUSER 0xF005 // Bad user name
- #define RSRV_BADGID 0xF006 // setgid error
- #define RSRV_BADUID 0xF007 // setuid error
- #define RSRV_BADINIT 0xF008 // initgroups error
- #define RSRV_EXEC 0xF009 // exec() failed
- #define RSRV_UNDEF 0xF00A // Undefined target
- #define RSRV_RSH 0xF00B // remote rsh exec() failed
-
- // -------------------------------------------------------------------------------------
- // handle to ExecServer exec process
- #define execHandle_t u_int
-
- // -------------------------------------------------------------------------------------
- @protocol RemoteClient // sent by server to client
- - (oneway void)commandOutput:(const char*)buffer len:(int)length;
- - (oneway void)commandDidCompleteWithError:(int)errorCode;
- @end
- #define RemoteClient_PROTOCOL
-
- // -------------------------------------------------------------------------------------
- @interface ExecServer : Object <NXSenderIsInvalid>
- { @public
-
- BOOL isRunning; // true if server is running
-
- int rootChild; // process handle
- id rootServer; // remote object id
-
- id methodDelegate; // class object id
-
- char mainAppPath[MAXPATHLEN + 1]; // path to app wrapper
- char mainAppHost[MAXHOSTNAMELEN + 1]; // main app host
- char mainAppServerName[256]; // main app server name
- char remoteHost[MAXHOSTNAMELEN + 1]; // remote host name
- char remoteServerName[256]; // remote server name
- char serverCommandName[MAXPATHLEN + 1]; // remote server command
-
- BOOL exitWhenDone; // exit when no clients
-
- }
-
- // -------------------------------------------------------------------------------------
-
- /* initializing ExecServer */
- // These must be sent prior to 'startServer' in order for them to be effective.
- - setExitWhenDone:(BOOL)flag;
- - setMethodDelegate:classId;
- - setMainAppPath:(const char*)appPath;
- - setMainAppServerName:(const char*)servName host:(const char*)hostName;
- - setRemoteHost:(const char*)hostName;
- - setRemoteServerName:(const char*)serverName;
- - setServerCommandName:(const char*)cmdPath;
-
- /* query ExecServer attributes */
- - (const char*)mainAppServerName;
- - (const char*)mainAppHost;
- - (const char*)remoteHost;
- - (const char*)remoteServerName;
-
- /* ExecServer startup */
- - (void)_runServer;
- - startServer;
-
- /* password check */
- - (BOOL)needUserPassword:(const char*)userName;
-
- /* ExecServer shell script command service */
- - (BOOL)isRunningAsRoot;
- - (execHandle_t)runCommand:(const char*)cmd
- withUser:(const char*)userName:(const char*)password
- forClient:(id <RemoteClient>)client
- killOnError:(BOOL)killOnError;
- - (execHandle_t)runCommand:(const char*)cmd
- forClient:(id <RemoteClient>)client
- killOnError:(BOOL)killOnError;
- - terminateCommand:(execHandle_t)runId;
- - killCommand:(execHandle_t)runId;
- - (BOOL)commandIsActive:(execHandle_t)runId;
- - shutDownServer;
-
- /* ExecServer class method service (requires setMethodDelegate: set) */
- - (int)perform:(SEL)method withArg:(const char*)arg
- withUser:(const char*)userName:(const char*)password;
-
- /* return description to specified error code */
- + (char*)errorDesc:(int)err;
-
- @end